package cn.hanyx.coder.design.pattern.behavioral.observer.demo01;

/**
 * Demo01
 *
 * @author hanyx
 * @date 2020/06/02
 */
public class Demo01 {
    public static void main(String[] args) {
        // 通知消息组装
        Message msg = new Message();
        msg.setMsg("触发通知消息.");

        // 封装被观察者类和观察者类的 一对多关系
        Subject subject = new ConcreteSubject();
        subject.registerObjserver(new ConcreteObserverOne());
        subject.registerObjserver(new ConcreteObserverTwo());

        // 被观察者类状态变更
        subject.notifyObjservers(msg);

    }
}
